package org.beanstech.util;

import java.sql.Connection;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

public class StaticHibernateUtil {

	private static MyHibernateUtil hibernateUtil;

	public static void setHibernateUtil(MyHibernateUtil hibernateUtil) {
		StaticHibernateUtil.hibernateUtil = hibernateUtil;
	}

	/*
	 * This method must be called before using Hibernate!
	 */
	public static void initialize() throws Exception {
		if (hibernateUtil == null) {
			hibernateUtil = MyHibernateUtil.getInstance();
		}
	}

	public static MyHibernateUtil getHibernateUtil() {
		return hibernateUtil;
	}

	public static SessionFactory getSessionFactory() {
		return hibernateUtil.getSessionFactory();
	}

	public static Session getSessionTL() {
		//System.out.println("Het Session");
		return hibernateUtil.getSessionTL();
	}

	public static Transaction startTransaction() {
		return hibernateUtil.startTransaction();
	}

	public static void closeSession() {
		hibernateUtil.closeSession();
	}

	public static void flushSession() {
		hibernateUtil.flushSession();
	}

	public static void flushAndCloseSession() {
		hibernateUtil.flushAndCloseSession();
	}

	public static void flushAndClearSession() {
		hibernateUtil.flushAndClearSession();
	}

	public static void commitTransaction() {
		hibernateUtil.commitTransaction();
	}

	public static void rollbackTransaction() {
		hibernateUtil.rollbackTransaction();
	}

	public static void shutdown() {
		hibernateUtil.shutdown();
	}


	public static void clearSession() {
		hibernateUtil.clearSession();
	}

}
